import { useState, useEffect } from 'react';
//闭包陷阱解决方案：传入函数
export default function Two() {
  const [count, setCount] = useState(0);
  useEffect(() => {
    setInterval(() => {
      //函数式更新
      setCount((count) => count + 1);
    }, 1000);
  }, []);
  return (
    <>
      <div>{count}</div>
    </>
  );
}
